/*
function add_one<T>(data: T): T {
    if (typeof data === 'number') {
        return (data + 1) as T;
    } else if (typeof data === 'string') {
        return (data + '1') as T;
    }
    throw new Error("类型不支持")
}

console.log(add_one(9))
console.log(add_one('9'))
console.log(add_one(true))
*/

enum CODE {
  FLIED,
  SUCCESS,
  NO_LOGIN = 401,
}

interface IData {
  code: number;
}

function f(data: IData) {
  console.log(CODE[data.code]);
}

f({ code: 401 });

class Dog {
  constructor(name: string, age: number) {
    this._name = name;
    this._age = age;
  }

  private _name: string;

  get name(): string {
    return this._name;
  }

  set name(value: string) {
    this._name = value;
  }

  private _age: number;

  get age(): number {
    return this._age;
  }

  set age(value: number) {
    this._age = value;
  }
}

const xiaobai = new Dog('小白', 12);
console.log(xiaobai);